// HTML5/history模式:==>import { createRouter, createWebHistory } from 'vue-router'
// hash模式
import { createRouter, createWebHashHistory } from 'vue-router'

// 引入路由组件
// import Login from '@/views/Login/Login.vue'
// import Home from '@/views/Home/Home.vue'
// import Layout from '@/views/Layout/Layout.vue'
// import Category from '@/views/Category/Category.vue'
// 配置路由的规则和vue2相同
const routes = [
  {
    path: '/',
    name: 'layout',
    component: () => import('@/views/Layout/Layout.vue'),
    children: [
      {
        path: '', // 默认展示本子路由
        name: 'home',
        component: () => import('@/views/Home/Home.vue')
      },
      {
        path: '/goods/:id', // 商品详情页路由
        name: 'goods',
        component: () => import('@/views/Goods/goodsDetail.vue')
      },
      {
        path: '/category/:id/:name', // 目录路由
        name: 'category',
        component: () => import('@/views/Category/Category.vue')
      }
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/Login/Login.vue')
  }
  // {
  //   path: '/',
  //   name: 'home',
  //   component: HomeView
  // },
  // {
  //   path: '/about',
  //   name: 'about',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  // }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
